package gouhuo.allbugs.top.service;

import com.baomidou.mybatisplus.extension.service.IService;
import gouhuo.allbugs.top.model.domain.User;
import gouhuo.allbugs.top.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 用户服务
 *
 * @author 15294780204
 * @description 针对表【user(用户表)】的数据库操作Service
 * @createDate 2022-11-03 19:47:32
 */
public interface UserService extends IService<User> {

    /**
     * 用户注册
     *
     * @param userPassword 用户密码
     * @return 新用户id
     */
    long userRegister(String phone, String userPassword, String checkPassword, String userName, String email, Integer gender);

    /**
     * 用户登录
     *
     * @param phone
     * @param userPassword
     * @param userCode
     * @param request
     * @return
     */

    UserVO userLogin(String phone, String userPassword, String userCode, int remember, int userId, HttpServletRequest request, HttpServletResponse response);


    /**
     * 用户注销
     *
     * @param request
     * @return
     */
    Boolean userLogout(Long userId, HttpServletRequest request, HttpServletResponse response, String cookie);

    /**
     * 用户反馈
     *
     * @param star
     * @param speak
     */
    boolean fromUserSpeak(UserVO loginUser, int star, String speak);

    /**
     * 根据标签搜索用户
     *
     * @param tagNameList
     * @return
     */
    List<UserVO> searchUsersByTags(List<String> tagNameList);

    /**
     * 更新用户信息
     *
     * @param user
     * @return
     */
    boolean updateUser(User user, UserVO loginUser, HttpServletRequest request);

    /**
     * 获取当前登录用户信息
     *
     * @param request
     * @param loop
     * @return
     */
    UserVO getLoginUser(HttpServletRequest request, Boolean loop);

    /**
     * 是否为管理员
     *
     * @param request
     * @return
     */
    boolean isAdmin(HttpServletRequest request);

    /**
     * 是否为管理员
     *
     * @param loginUser
     * @return
     */
    boolean isAdmin(UserVO loginUser);

    /**
     * 匹配用户
     *
     * @param num
     * @param loginUser
     * @return
     */
    List<UserVO> matchUsers(long num, UserVO loginUser);

    /**
     * 根据昵称搜索用户
     *
     * @param searchMessage
     * @return
     */
    List<UserVO> searchUsers(String searchMessage);


    /**
     * 向刚注册的用户发送系统消息
     */
    void allUserMsg(Long userId);

}